.class public Les/cd0;
.super Ljava/lang/Object;
.source "NtlmFunctions.java"


# static fields
.field public static final a:Ljava/nio/charset/Charset;

.field private static b:Ljava/security/SecureRandom;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    const-string v0, "UTF-16LE"

    .line 1
    invoke-static {v0}, Ljava/nio/charset/Charset;->forName(Ljava/lang/String;)Ljava/nio/charset/Charset;

    move-result-object v0

    sput-object v0, Les/cd0;->a:Ljava/nio/charset/Charset;

    .line 2
    new-instance v0, Ljava/security/SecureRandom;

    invoke-direct {v0}, Ljava/security/SecureRandom;-><init>()V

    sput-object v0, Les/cd0;->b:Ljava/security/SecureRandom;

    return-void
.end method

.method public static a()Ljava/security/SecureRandom;
    .locals 1

    .line 32
    sget-object v0, Les/cd0;->b:Ljava/security/SecureRandom;

    return-object v0
.end method

.method public static a(Ljava/lang/String;)[B
    .locals 1

    if-nez p0, :cond_0

    const/4 p0, 0x0

    new-array p0, p0, [B

    goto :goto_0

    .line 5
    :cond_0
    sget-object v0, Les/cd0;->a:Ljava/nio/charset/Charset;

    invoke-virtual {p0, v0}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B

    move-result-object p0

    :goto_0
    return-object p0
.end method

.method public static a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[B
    .locals 0

    .line 1
    invoke-static {p0}, Les/cd0;->a(Ljava/lang/String;)[B

    move-result-object p0

    .line 2
    new-instance p1, Ljcifs/util/MD4;

    invoke-direct {p1}, Ljcifs/util/MD4;-><init>()V

    .line 3
    invoke-virtual {p1, p0}, Ljava/security/MessageDigest;->update([B)V

    .line 4
    invoke-virtual {p1}, Ljava/security/MessageDigest;->digest()[B

    move-result-object p0

    return-object p0
.end method

.method public static a([B)[B
    .locals 7

    const/16 v0, 0x8

    new-array v0, v0, [B

    .line 12
    invoke-static {}, Les/cd0;->a()Ljava/security/SecureRandom;

    move-result-object v1

    invoke-virtual {v1, v0}, Ljava/security/SecureRandom;->nextBytes([B)V

    .line 13
    invoke-static {}, Lcom/hierynomus/msdtyp/a;->a()J

    move-result-wide v1

    const/4 v3, 0x0

    if-nez p0, :cond_0

    new-array p0, v3, [B

    .line 14
    :cond_0
    new-instance v4, Lcom/hierynomus/protocol/commons/buffer/Buffer$b;

    sget-object v5, Lcom/hierynomus/protocol/commons/buffer/a;->a:Lcom/hierynomus/protocol/commons/buffer/a;

    invoke-direct {v4, v5}, Lcom/hierynomus/protocol/commons/buffer/Buffer$b;-><init>(Lcom/hierynomus/protocol/commons/buffer/a;)V

    const/4 v5, 0x1

    .line 15
    invoke-virtual {v4, v5}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->a(B)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 16
    invoke-virtual {v4, v5}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->a(B)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 17
    invoke-virtual {v4, v3}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->c(I)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    const-wide/16 v5, 0x0

    .line 18
    invoke-virtual {v4, v5, v6}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->b(J)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 19
    invoke-virtual {v4, v1, v2}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->a(J)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 20
    invoke-virtual {v4, v0}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->a([B)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 21
    invoke-virtual {v4, v5, v6}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->b(J)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 22
    invoke-virtual {v4, p0}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->a([B)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 23
    invoke-virtual {v4, v5, v6}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->b(J)Lcom/hierynomus/protocol/commons/buffer/Buffer;

    .line 24
    invoke-virtual {v4}, Lcom/hierynomus/protocol/commons/buffer/Buffer;->d()[B

    move-result-object p0

    return-object p0
.end method

.method public static a([B[B)[B
    .locals 0
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lcom/hierynomus/ntlm/NtlmException;
        }
    .end annotation

    .line 29
    :try_start_0
    invoke-static {p0}, Les/cd0;->b([B)Ljavax/crypto/Cipher;

    move-result-object p0

    .line 30
    invoke-virtual {p0, p1}, Ljavax/crypto/Cipher;->doFinal([B)[B

    move-result-object p0
    :try_end_0
    .catch Ljavax/crypto/BadPaddingException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljavax/crypto/IllegalBlockSizeException; {:try_start_0 .. :try_end_0} :catch_0

    return-object p0

    :catch_0
    move-exception p0

    goto :goto_0

    :catch_1
    move-exception p0

    .line 31
    :goto_0
    new-instance p1, Lcom/hierynomus/ntlm/NtlmException;

    invoke-direct {p1, p0}, Lcom/hierynomus/ntlm/NtlmException;-><init>(Ljava/lang/Throwable;)V

    throw p1
.end method

.method public static a([B[B[B)[B
    .locals 2

    const/4 v0, 0x2

    new-array v0, v0, [[B

    const/4 v1, 0x0

    aput-object p1, v0, v1

    const/4 p1, 0x1

    aput-object p2, v0, p1

    .line 25
    invoke-static {p0, v0}, Les/cd0;->a([B[[B)[B

    move-result-object p0

    .line 26
    array-length p1, p0

    array-length v0, p2

    add-int/2addr p1, v0

    new-array p1, p1, [B

    .line 27
    array-length v0, p0

    invoke-static {p0, v1, p1, v1, v0}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    .line 28
    array-length p0, p0

    array-length v0, p2

    invoke-static {p2, v1, p1, p0, v0}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V

    return-object p1
.end method

.method public static varargs a([B[[B)[B
    .locals 3

    const-string v0, "HmacMD5"

    :try_start_0
    const-string v1, "BC"

    .line 6
    invoke-static {v0, v1}, Ljavax/crypto/Mac;->getInstance(Ljava/lang/String;Ljava/lang/String;)Ljavax/crypto/Mac;

    move-result-object v1

    .line 7
    new-instance v2, Ljavax/crypto/spec/SecretKeySpec;

    invoke-direct {v2, p0, v0}, Ljavax/crypto/spec/SecretKeySpec;-><init>([BLjava/lang/String;)V

    invoke-virtual {v1, v2}, Ljavax/crypto/Mac;->init(Ljava/security/Key;)V

    const/4 p0, 0x0

    .line 8
    :goto_0
    array-length v0, p1

    if-ge p0, v0, :cond_0

    .line 9
    aget-object v0, p1, p0

    invoke-virtual {v1, v0}, Ljavax/crypto/Mac;->update([B)V

    add-int/lit8 p0, p0, 0x1

    goto :goto_0

    .line 10
    :cond_0
    invoke-virtual {v1}, Ljavax/crypto/Mac;->doFinal()[B

    move-result-object p0
    :try_end_0
    .catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_2
    .catch Ljava/security/InvalidKeyException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/security/NoSuchProviderException; {:try_start_0 .. :try_end_0} :catch_0

    return-object p0

    :catch_0
    move-exception p0

    goto :goto_1

    :catch_1
    move-exception p0

    goto :goto_1

    :catch_2
    move-exception p0

    .line 11
    :goto_1
    new-instance p1, Lcom/hierynomus/ntlm/NtlmException;

    invoke-direct {p1, p0}, Lcom/hierynomus/ntlm/NtlmException;-><init>(Ljava/lang/Throwable;)V

    goto :goto_3

    :goto_2
    throw p1

    :goto_3
    goto :goto_2
.end method

.method private static b([B)Ljavax/crypto/Cipher;
    .locals 3

    const-string v0, "RC4"

    :try_start_0
    const-string v1, "BC"

    .line 5
    invoke-static {v0, v1}, Ljavax/crypto/Cipher;->getInstance(Ljava/lang/String;Ljava/lang/String;)Ljavax/crypto/Cipher;

    move-result-object v1

    .line 6
    new-instance v2, Ljavax/crypto/spec/SecretKeySpec;

    invoke-direct {v2, p0, v0}, Ljavax/crypto/spec/SecretKeySpec;-><init>([BLjava/lang/String;)V

    const/4 p0, 0x1

    .line 7
    invoke-virtual {v1, p0, v2}, Ljavax/crypto/Cipher;->init(ILjava/security/Key;)V
    :try_end_0
    .catch Ljava/security/NoSuchAlgorithmException; {:try_start_0 .. :try_end_0} :catch_3
    .catch Ljavax/crypto/NoSuchPaddingException; {:try_start_0 .. :try_end_0} :catch_2
    .catch Ljava/security/NoSuchProviderException; {:try_start_0 .. :try_end_0} :catch_1
    .catch Ljava/security/InvalidKeyException; {:try_start_0 .. :try_end_0} :catch_0

    return-object v1

    :catch_0
    move-exception p0

    goto :goto_0

    :catch_1
    move-exception p0

    goto :goto_0

    :catch_2
    move-exception p0

    goto :goto_0

    :catch_3
    move-exception p0

    .line 8
    :goto_0
    new-instance v0, Lcom/hierynomus/ntlm/NtlmException;

    invoke-direct {v0, p0}, Lcom/hierynomus/ntlm/NtlmException;-><init>(Ljava/lang/Throwable;)V

    throw v0
.end method

.method public static b(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[B
    .locals 2

    .line 1
    invoke-static {p0, p1, p2}, Les/cd0;->a(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)[B

    move-result-object p0

    .line 2
    invoke-virtual {p1}, Ljava/lang/String;->toUpperCase()Ljava/lang/String;

    move-result-object p1

    invoke-static {p1}, Les/cd0;->a(Ljava/lang/String;)[B

    move-result-object p1

    .line 3
    invoke-static {p2}, Les/cd0;->a(Ljava/lang/String;)[B

    move-result-object p2

    const/4 v0, 0x2

    new-array v0, v0, [[B

    const/4 v1, 0x0

    aput-object p1, v0, v1

    const/4 p1, 0x1

    aput-object p2, v0, p1

    .line 4
    invoke-static {p0, v0}, Les/cd0;->a([B[[B)[B

    move-result-object p0

    return-object p0
.end method
